<template>
	<view v-if="list.length > 0" class="content">
		<view style="height: 10rpx;"></view>
		<radio-group @change="radioChange">
			<label class="wid90 mar mar-top30 dis disAl disJuB" v-for="(item,index) in list" :key="item.id">
				<view>{{item.name}}</view>
				<radio color="#035DFF" :value="item.id" :checked="item.id == level" />
			</label>
		</radio-group>
		<view class="wid100 dis disJuC mar-top30">
			<view class="dis disAl disJuC borRad10 foSi40 coFFF wid90" @click="baocun()"
				style="height: 84rpx;background-color: #035DFF;">保存</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id: 0,
				level: 0,
				list: []
			}
		},
		onLoad(option) {
			this.yuan_userinfo = uni.getStorageSync('yuan_userinfo')
			this.id = option.id
			this.level = option.level
			this.getList()
		},
		onShow() {},
		methods: {
			getList() {
				var that = this;
				uni.request({
					url: that.global.url + '/api/qianyu_petrol/gasstation_user_level',
					method: "POST",
					header: {
						'site-id': that.global.site_id,//自定义请求头信息
						'token': uni.getStorageSync('token')
					},
					data: {},
					success(res) {
						let result = res.data
						console.log(result)
						if (result.code == 1) {
							that.list = result.data
						}
					}
				})
			},
			baocun() {
				var that = this;
				uni.request({
					url: that.global.url + '/api/qianyu_petrol/gasstation_clerk_operate_user',
					method: "POST",
					header: {
						'site-id': that.global.site_id,//自定义请求头信息
						'token': uni.getStorageSync('token')
					},
					data: {
						'gas_station_id': that.yuan_userinfo.gas_station_id,
						'clerk_id' : that.yuan_userinfo.id,
						'id' : that.id,
						'type' : 0,
						'value' : that.level,
						'notes' : ''
					},
					success(res) {
						let result = res.data
						console.log(result)
						if (result.code == 1) {
							uni.navigateBack()
						}
					}
				})
			},
			radioChange: function(evt) {
				this.level = evt.detail.value
			},
			tiaozhuan(url) {
				uni.navigateTo({
					url: url
				})
			}
		}
	}
</script>

<style>
	.content {
		background: #F8F9FD;
		height: 100vh;
	}
	.xia{
		height: 1rpx;
		background-color: #E5E5E5;
	}
</style>
